import { useEffect, useState } from "react"
import { ListApi } from "../../api/user"
import { useNavigate } from "react-router-dom"
function Index() {
  const nav=useNavigate()
  const [list,setList]=useState()
  const getdata=async()=>{
    const res=await ListApi()
    // console.log(res.rows);
    setList(res.rows)
  }
  useEffect(()=>{
    getdata()
  },[])
  return (
    <div>
      {
        list && list.map((item,index)=>{
          return <div key={index} style={{margin:"30px"}} onClick={()=>nav(`/detail?id=${item.id}`)}>
            <p>文章内容:{item.content}</p>
            <p>创建时间:{item.createdAt}</p>
            <p>文章标题:{item.title}</p>
            <p>结束时间:{item.updatedAt}</p>
          </div>
        })
      }
    </div>
  )
}

export default Index
